﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Presentation.Shell.Interfaces;
using Microsoft.Practices.Unity;
using Presentation.Module.Setup.Interfaces;
using Presentation.Setup.Views;
using Presentation.Module.Setup.Interfaces.Views;
using Presentation.Module.Setup.Interfaces.ViewModels;
using Presentation.Module.Setup.Interfaces.Services;
using System.Windows;
using Application.Interfaces;

namespace Presentation.Module.Setup
{
    public class SetupModule : IPresentationModule
    {
        public IUnityContainer Container { get; private set; }

        public SetupModule(IUnityContainer container)
        {
            // Keep an instance of the container for later use
            this.Container = container;
            
            #warning move to config file
            // register mappings from interfaces to implementations, standard Dependency Injection stuff.
            container.RegisterType<ITaskCategoriesView, TaskCategoriesView>();
            container.RegisterType<ITaskCategoriesViewModel, TaskCategoriesViewModel>();

            container.RegisterType<IEditSkillView, EditSkillView>();
            container.RegisterType<IEditSkillViewModel, EditSkillViewModel>();

            container.RegisterType<IAddSkillView, AddSkillView>();
            container.RegisterType<IAddSkillViewModel, AddSkillViewModel>();

            container.RegisterType<IAddTaskView, AddTaskView>();
            container.RegisterType<IAddTaskViewModel, AddTaskViewModel>();

            //container.RegisterType<ISkillsService, MockSkillService>();// mock implementation defined below
            container.RegisterType<ISkillsService, Presentation.Module.Setup.Services.SkillsService>();// mock implementation defined below
            container.RegisterType<ISetupManagementService, Application.Setup.SetupManagementService>();
            container.RegisterType<Domain.Setup.Skills.ISetupSkillDomainService, Domain.Setup.Skills.SkillsDomainService>();
            container.RegisterType<Domain.Setup.Skills.ISkillRepository, Infrastructure.Data.Setup.Repositories.SkillRepository>();
            container.RegisterType<Domain.Setup.Tasks.ITaskRepository, Infrastructure.Data.Setup.Repositories.TaskRepository>();
        }

        // this name isb used for display on the menu
        public string Name
        {
            get
            {
                return "VPL System Setup";
            }
        }

        // Provide a ModuleLandingPage to Render when control passes to the selected module
        public IModuleLandingPage LandingPage
        {
            get 
            {
                return Container.Resolve<SetupLandingPage>();
            }
        }
    }
}
